<?php
/**
 * 客服消息处理
 * @App	
 * @Group 
 * @Action WeChatCustom
 * @author lilei
 * @date 2018年8月29日
 *
 */
namespace app\common\service\wechat;
class WeChatCustom extends WeChatService {
	/**
	 * wechat操作句柄
	 * @var object | \WeChat\Custom
	 */
	private $handle;

    /**
     * 初始化方法
     */
	public function __init() {
		$this->handle = new \WeChat\Custom(self::$option);
	}

	/**
	 * 添加客服
	 * @param string $kf_account 客服账号
     * @param string $nickname 客服昵称
     * @param string $password 账号密码
	 */
	public function addAccount($kf_account, $nickname, $password) {
		$this->handle->addAccount($kf_account, $nickname, $password);
	}
	
	/**
	 * 发送文本消息
	 * @param string $open_id OPEN_ID
	 * @param string $msg 消息内容
	 */
	public function sendTxtMsg( $open_id, $msg ) {
		$data = array(
				"touser" => $open_id,
				"msgtype" => "text",
				"text" => array(
						"content"	=> $msg
				),
		);
		$this->handle->send($data);
	}
	
	/**
	 * 发送图片消息
	 * @param string $open_id
	 * @param string $media_id
	 */
	public function sendImgMsg( $open_id, $media_id ) {		
		$data = array(
				"touser" => $open_id,
				"msgtype" => "image",
				"image" => array(
						"media_id"	=> $media_id
				),
		);
		$this->handle->send($data);
	}
	
}